{extend name="platform/base" /}
{block name="resources"/}
<style type="text/css">
.tal{text-align:left;}
textarea{width:535px;height:150px;}
</style>
{/block}
{block name="main"}

<div class="row padder-v">
	<div class="col-sm-9" style="width:73%;"></div>
</div>
<section class="panel panel-default">
	<div class="table-responsive">
		<table class="table table-striped b-t b-light text-sm">
			<thead>
				<tr>
					<th width="1%"><input type="checkbox"></th>
					<th class="center" width="7%">用户昵称</th>
					<th class="center" width="24%">反馈内容</th>
					<th class="center" width="12%">反馈时间</th>
					<th class="center" width="24%">回复内容</th>
					<th class="center" width="12%">回复时间</th>
					<th class="center" width="20">操作</th>
				</tr>
			</thead>
			<tbody id="list">
				<tr></tr>
			</tbody>
		</table>
	</div>
	{include file="platform/page" /}
</section>
<!-- 提现详情模态框（Modal） -->
<div class="modal fade" id="details" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">回复</h4>
            </div>
            <div class="modal-body">
            	<div class="modal-infp-style">
            		<table>
            			<tr>
            				<td><textarea id="reply"></textarea></td>
            			</tr>
            		</table>
            	</div>
            </div>
            <div class="modal-footer">
               <button class="btn btn-info" onclick="replyOpinion()" id="butSubmit" data-dismiss="modal" aria-hidden="true" style="display:inline-block;">确定</button>
               <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<input type="hidden" id="id"/>
{/block}
{block name="script"}

<script type="text/javascript">
$(function(){
	LoadingInfo(1);
})
	function LoadingInfo(page_index) {
		var search_text = $("#search_text").val();
		$.ajax({
			type : "post",
			url : "PLATFORM_MAIN/member/feedbacklist",
			async : true,
			data : {
				"page_index" : page_index, "search_text" :  search_text
			},
			success : function(data) {
			//	alert(JSON.stringify(data));
				var html = '';
				$("#total_count_num").text(data["total_count"]);
				$("#page_count_num").text(data["page_count"]);
				$("#page_count").val(data["page_count"]);
				$("#pageNumber a").remove();
				if (data["data"].length > 0) {
					for (var i = 0; i < data["data"].length; i++) {
						html += '<tr align="center">';
						html += '<td><div class="cell"><label ><input name="sub" type="checkbox" value="'+ data["data"][i]["id"]+'" ></label></div></td>';
					    html += '<td>' + data["data"][i]["nick_name"]+'</td>';	
						html += '<td align="left">' + data['data'][i]['opinion']+ '</td>';
						html += '<td>' + data['data'][i]['create_time']+ '</td>';
						html += '<td align="left">' + data['data'][i]['reply']+ '</td>';
						if(data['data'][i]['reply_time']==0){
							html += '<td></td>';
						}else{
						   html += '<td>' + data['data'][i]['reply_time']+ '</td>';
						}
						
						if(data['data'][i]['reply']==''){
							html += '<td><a href="javascript:;" onclick="reply('+ data['data'][i]['id'] +')">回复</a>&nbsp;&nbsp;&nbsp;<a href="javascript:deleteOpinion('+data['data'][i]['id']+');">删除</a></td>';
						}else{
							html += '<td><a href="javascript:deleteOpinion('+data['data'][i]['id']+');">删除</a></td>';
						}
						html += '</tr>';
					}
				} else {
					html += '<tr align="center"><th colspan="5">暂无符合条件的数据记录</th></tr>';
				}
				$("#list").html(html);
					var totalpage = $("#page_count").val();
				if (totalpage == 1) {
					changeClass("all");
				}
				var $html = pagenumShow(jumpNumber,totalpage,{$pageshow})
				$("#pageNumber").append($html);
				
			}
		});
	}
	//全选
	function CheckAll(event){
		var checked = event.checked;
		$(".style0list tbody input[type = 'checkbox']").prop("checked",checked);
	}
	function deleteOpinion(id){
		$.ajax({
			type : "post",
			url : "PLATFORM_MAIN/member/deleteopinion",
			data : {
				'id' : id
			},
			async : true,
			success : function(data) {
				if (data['code'] > 0) {
					    showMessage('success', data["message"]);
					    location.href="PLATFORM_MAIN/member/feedbacklist";
				} else {
						showMessage('error', data["message"]);
					
				}
			}
		});
	}
	//回复模态显示
	function reply(id){
		$("#details").modal("show");
		$('#id').val(id);
	}
	//回复
	function replyOpinion(){
		var id = $('#id').val();
		var reply = $('#reply').val();
		$.ajax({
			type : "post",
			url : "PLATFORM_MAIN/member/replyopinion",
			data : {
				'id' : id,
				'reply' : reply,
			},
			async : true,
			success : function(data) {
				if (data['code'] > 0) {
					    showMessage('success', data["message"]);
					    location.href="PLATFORM_MAIN/member/feedbacklist";
				} else {
						showMessage('error', data["message"]);
					
				}
			}
		});
		
	}
	
	
	
</script>
{/block}